//
//  YKClientNeedsViewController.m
//  YunKang
//
//  Created by leoking870 on 2017/10/3.
//  Copyright © 2017年 leoking870. All rights reserved.
//

#import "YKClientNeedsViewController.h"
#import "YKClientListHeaderView.h"
#import "YKClientNeedsItem.h"
#import "YKClientNeedsDetailViewController.h"
#import "YKClientNeedsV2Item.h"
@interface YKClientNeedsViewController ()

@end

@implementation YKClientNeedsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"客户需求";
    
//    YKClientListHeaderView* headerView = [[YKClientListHeaderView alloc]initWithTitles:@[@"客户名称",@"药品名称",@"提出日期"] weights:@[@1,@1,@1]];
//    [self.view addSubview:headerView];
//    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.top.trailing.equalTo(self.view);
//    }];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.tableFooterView = [UIView new];
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
//        make.leading.bottom.trailing.equalTo(self.view);
//        make.top.equalTo(headerView.mas_bottom);
        make.edges.equalTo(self.view);
    }];
    
    self.dataSource.totalPageKey = @"page.totalpage";
    self.dataSource.currentPageKey = @"curpage";
    [self startLoadData];
}

- (NSDictionary *)pageViewControllerParameters {
    return @{
             kTFPageViewControllerItemClass: [YKClientNeedsV2Item class],
             kTFPageViewControllerModelClass:[YKClientNeedsModel class],
             kTFPageViewControllerRequestURL:@"personalCentr/searchCustomerDemandList.htm",
             kTFPageViewControllerDataKeyPath:@"list",
             kTFPageViewControllerRequestParameter:@{@"c_name":[self searchText]?:@""}
             };
}

- (void)customizeItem:(TFTableViewItem *)item {
    @weakify(self)
    item.hideSeparator = NO;
    item.separatorSunk = NO;
    item.selectionHandler = ^(__kindof YKClientNeedsItem *item, NSIndexPath *indexPath) {
        YKClientNeedsDetailViewController *vc = [[YKClientNeedsDetailViewController alloc]init];
        vc.m_id = item.model.ID;
        [self_weak_.navigationController pushViewController:vc animated:YES];
    };
}
- (void)beginSearchWithText:(NSString *)text {
    [self startLoadData];
}

@end
